//
//  NewMediaPromotionCell.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/13.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "NewMediaPromotionCell.h"

@implementation NewMediaPromotionCell

- (void)awakeFromNib {
    // Initialization code
    [self setAutoLayout];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(NewMediaPromotionModel *)model
{
//    NSLog(@"imm====%@",model.imageUrl);
    [_imgView setImageWithURL:[NSURL URLWithString:model.imageUrl]];
    [_titleNameLabel setText:model.title];
    [_typeLabel setText:[NSString stringWithFormat:@"%@ ",   model.typeName]];
     NSString *timeStr = [model.pubTime substringToIndex:16];
    [_timeLabel setText:timeStr];
    if ([model.typeCode isEqualToString:@"custom"]) {
        [_typeLabel setBackgroundColor:[UIColor colorWithRed:75.0/255.0 green:115.0/255.0 blue:25.0/255.0 alpha:1.0]];
    }
    else
    {
        [_typeLabel setBackgroundColor:[UIColor redColor]];
    }
  }
-(void)setAutoLayout
{
    [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@70);
    }];
    [_titleNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imgView.mas_right).with.offset(8);
        make.top.equalTo(_imgView.mas_top).with.offset(3).with.priorityHigh();
        make.right.equalTo(self.mas_right).with.offset(-8);
        make.bottom.equalTo(_typeLabel.mas_top).with.priorityLow();
    }];
    [_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_imgView.mas_right).with.offset(8);
        make.bottom.equalTo(_imgView.mas_bottom).with.offset(-8);
//        make.right.equalTo(self.mas_right).with.offset(-8);
        make.height.equalTo(@13);
        
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.mas_right).with.offset(-13);
        make.bottom.equalTo(_imgView.mas_bottom).with.offset(-8);
        //        make.right.equalTo(self.mas_right).with.offset(-8);
        make.height.equalTo(@13);
        make.width.equalTo(@110);
        
    }];
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.bottom.equalTo(self.mas_bottom).with.offset(-1);
        //        make.right.equalTo(self.mas_right).with.offset(-8);
        make.height.equalTo(@0.5);
           }];


}


@end
